using System;
using System.Collections.Generic;


namespace DataObjects
{
	[Serializable]
	public class Company: IEquatable<Company>
	{

		#region Private Members

		private int _company_id; 
		private string _company_name; 
		private string _code; 
		private string _address; 
		private string _telephone; 
		private string _fax; 
		private string _tax_code; 
		private string _remark; 
		private bool? _is_current; 		
		#endregion

		#region Constructor

		public Company()
		{
			_company_id = 0; 
			_company_name = String.Empty; 
			_code = String.Empty; 
			_address = String.Empty; 
			_telephone = String.Empty; 
			_fax = String.Empty; 
			_tax_code = String.Empty; 
			_remark = String.Empty; 
			_is_current = new bool?(); 
		}
		#endregion // End of Default ( Empty ) Class Constuctor

		#region Required Fields Only Constructor
		/// <summary>
		/// required (not null) fields only constructor
		/// </summary>
		public Company(
			int company_id)
			: this()
		{
			_company_id = company_id;
			_company_name = String.Empty;
			_code = String.Empty;
			_address = String.Empty;
			_telephone = String.Empty;
			_fax = String.Empty;
			_tax_code = String.Empty;
			_remark = String.Empty;
			_is_current = null;
		}
		#endregion // End Constructor

		#region Public Properties
			
		public virtual int CompanyId
		{
			get
			{ 
				return _company_id;
			}
			set
			{
				_company_id = value;
			}

		}
			
		public virtual string CompanyName
		{
			get
			{ 
				return _company_name;
			}

			set	
			{	
				if(  value != null &&  value.Length > 100)
					throw new ArgumentOutOfRangeException("Invalid value for CompanyName", value, value.ToString());
				
				_company_name = value;
			}
		}
			
		public virtual string Code
		{
			get
			{ 
				return _code;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for Code", value, value.ToString());
				
				_code = value;
			}
		}
			
		public virtual string Address
		{
			get
			{ 
				return _address;
			}

			set	
			{	
				if(  value != null &&  value.Length > 100)
					throw new ArgumentOutOfRangeException("Invalid value for Address", value, value.ToString());
				
				_address = value;
			}
		}
			
		public virtual string Telephone
		{
			get
			{ 
				return _telephone;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for Telephone", value, value.ToString());
				
				_telephone = value;
			}
		}
			
		public virtual string Fax
		{
			get
			{ 
				return _fax;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for Fax", value, value.ToString());
				
				_fax = value;
			}
		}
			
		public virtual string TaxCode
		{
			get
			{ 
				return _tax_code;
			}

			set	
			{	
				if(  value != null &&  value.Length > 50)
					throw new ArgumentOutOfRangeException("Invalid value for TaxCode", value, value.ToString());
				
				_tax_code = value;
			}
		}
			
		public virtual string Remark
		{
			get
			{ 
				return _remark;
			}

			set	
			{	
				if(  value != null &&  value.Length > 200)
					throw new ArgumentOutOfRangeException("Invalid value for Remark", value, value.ToString());
				
				_remark = value;
			}
		}
			
		public virtual bool? IsCurrent
		{
			get
			{ 
				return _is_current;
			}
			set
			{
				_is_current = value;
			}

		}
			
				
		#endregion 

		#region Public Functions

		#endregion //Public Functions

		#region Equals And HashCode Overrides
		/// <summary>
		/// local implementation of Equals based on unique value members
		/// </summary>
		public override bool Equals( object obj )
		{
			if( this == obj ) return true;
			if( ( obj == null ) || ( obj.GetType() != this.GetType() ) ) return false;
			Company castObj = (Company)obj; 
			return ( castObj != null ) &&
				( this._company_id == castObj.CompanyId );
		}
		
		/// <summary>
		/// local implementation of GetHashCode based on unique value members
		/// </summary>
		public override int GetHashCode()
		{
			
			int hash = 57; 
			hash = 27 ^ hash ^ _company_id.GetHashCode();
			return hash; 
		}
		#endregion
		
		#region IEquatable members

		public bool Equals(Company other)
		{
			if (other == this)
				return true;
		
			return ( other != null ) &&
				( this._company_id == other.CompanyId );
				   
		}

		#endregion
		
	}
}
